package com.btex.app.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.btex.app.R;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

/**
 * @author zy zhangyi <zhangyi, 1104745049@QQ.com
 * @version v1.0
 * @project study1
 * @Description
 * @encoding UTF-8
 * @date 2018/8/17
 * @time 下午4:12
 * @修改记录 <pre>
 * 版本       修改人         修改时间         修改内容描述
 * --------------------------------------------------
 * <p>
 * --------------------------------------------------
 * </pre>
 */

public class OTCStateImagAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context mContext;

    public OTCStateImagAdapter(@Nullable List<String> data, Context context) {
        super(R.layout.item_otc_state_imag, data);
        mContext = context;
    }

    @Override
    protected void convert(final BaseViewHolder helper, String item) {


        ImageView imageView = (ImageView) helper.getView(R.id.item_state_otc_imag);
        ImageView item_state_otc_del_imag = (ImageView) helper.getView(R.id.item_state_otc_del_imag);
        Glide.with(mContext).load(item).into(imageView);

        item_state_otc_del_imag.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                OTCStateImagAdapter.this.remove(helper.getPosition());
                OTCStateImagAdapter.this.notifyDataSetChanged();
                EventBus.getDefault().post(String.valueOf(helper.getPosition()));
            }
        });

    }
}
